<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            height: 200px;
            width: 200px;
            background-color: pink;
        }
    </style>
</head>

<body>
    <div></div>
    <script>
        const div = document.querySelector('div');
        // 鼠标移入事件源 触发事件
        div.addEventListener('mouseenter', function () {
            console.log(`轻轻的我来了`);
        })
        // 鼠标离开事件源 触发事件
        div.addEventListener('mouseleave', function () {
            console.log(`轻轻的我走了`);
        })

    </script>
</body>

</html>